<template>
    <view>
        <navigationBar :backType="2" navigationTitle="设置" />

        <view class="wrap paddingBottom">
            <view class="wrap-userInfo">
                <view class="avatar-bg">
                    <image :src="userInfo.avatar" mode="scaleToFill" />
                </view>

                <view class="list">
                    <view class="item flex align-center just-between">
                        <view class="title f-28"> 昵称 </view>

                        <input
                            class="value f-28"
                            placeholder="----"
                            placeholder-class="place"
                            v-model="userInfo.nickname"
                            disabled
                        />
                    </view>

                    <view class="item flex align-center just-between">
                        <view class="title f-28"> 注册时间 </view>

                        <picker mode="date" disabled>
                            <input
                                disabled
                                class="value"
                                placeholder="----"
                                v-model="userInfo.createtime_text"
                            />
                        </picker>
                    </view>

                    <view class="item flex align-center just-between">
                        <view class="title f-28"> 支付宝账号 </view>

                        <view class="value flex align-center just-end f-28">
                            <block v-if="userInfo.zfb_info_type !== 1">
                                <view class="tit"> 暂无 </view>
                                <view class="set" @click="onSet"> 去设置 </view>
                            </block>
                            <block v-else>
                                <view class="tit flex column" @click="onSet">
                                    <text
                                        >姓名：{{
                                            userInfo.zfb_info.HideName
                                        }}</text
                                    >
                                    <text
                                        >账号：{{
                                            userInfo.zfb_info.HideMobile
                                        }}</text
                                    >
                                </view>
                                <view class="set" @click="onSet"> 修改</view>
                            </block>
                        </view>
                    </view>
                </view>
            </view>

            <view class="wrap-agree-list">
                <block v-for="(item, index) in agreeList" :key="index">
                    <view
                        class="item flex align-center just-between"
                        @click="$handle(item)"
                    >
                        <view class="title f-28">
                            {{ item.title }}
                        </view>

                        <image
                            class="arrow"
                            :src="getImageURL('common/arrow.png')"
                        />
                    </view>
                </block>
            </view>
        </view>

        <view class="wrap-footer safe-area flex just-between align-center">
            <view class="item cancel f-28" @click.stop="onCancel" v-if="false">
                注销账号
            </view>
            <view class="item logout f-28" @click.stop="onLogout">
                退出登录
            </view>
        </view>
    </view>
</template>

<script>
import { getUserInfo } from "@/API/API/mine.js";
export default {
    data() {
        return {
            agreeList: [
                {
                    title: "隐私协议",
                    handle: function (item) {
                        uni.navigateTo({
                            url: "/subPages/technician/recruit/rich?type=0",
                        });
                    },
                },
                {
                    title: "服务协议",
                    handle: () => {
                        uni.navigateTo({
                            url: "/subPages/technician/recruit/rich?type=1",
                        });
                    },
                },
                // {
                //     title: "屏蔽列表",
                //     handle: () => {
                //     },
                // },
            ],
            userInfo: {},
        };
    },
    onShow() {
        this.getUserInfo();
    },
    methods: {
        /**
         * 注销账号
         */
        onCancel() {},
        /**
         * 退出登录
         */
        onLogout() {
            uni.showModal({
                title: "提示",
                content: "确定要退出登录吗？",
                success: (res) => {
                    uni.removeStorageSync("___token___");
                    uni.removeStorageSync("dealer_id");
                    uni.reLaunch({
                        url: "/subPages/technician/tabBar/home",
                    });
                },
            });
        },
        /**
         * 获取信息
         */
        getUserInfo() {
            getUserInfo()
                .then((res) => {
                    res.data.jointime_text = new Date(
                        res.data.jointime
                    ).toLocaleDateString();
                    this.userInfo = res.data;
                })
                .catch((err) => {});
        },
        onSet() {
            uni.navigateTo({
                url:
                    "/subPages/technician/recruit/addAlipay?info=" +
                    JSON.stringify(this.userInfo.zfb_info) +
                    "&type=1",
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.wrap {
    --bottom-height: 140rpx;

    .wrap-userInfo {
        width: 100%;
        background-color: white;
        padding-top: 60rpx;

        .avatar-bg {
            margin: 0 auto;
            width: 126rpx;
            height: 126rpx;
            border-radius: 50%;
            overflow: hidden;
            background-color: #eee;

            image {
                width: 100%;
                height: 100%;
                border-radius: 50%;
            }
        }

        .list {
            margin-top: 50rpx;
            width: 100%;
            overflow: hidden;

            .item {
                padding: 30rpx;
                width: 100%;
                box-sizing: border-box;
                overflow: hidden;

                .title {
                    color: $title-color;
                }

                .value {
                    text-align: right;
                    margin-left: 20rpx;
                    width: 500rpx;
                    height: 40rpx;
                    color: #999999;

                    .tit {
                        color: #999999;
                    }
                    .set {
                        margin-left: 14rpx;
                        color: $theme-color;
                    }
                }
                .place {
                    color: #999999;
                }
            }
        }
    }

    .wrap-agree-list {
        margin-top: 20rpx;
        width: 100%;
        overflow: hidden;
        padding: 0rpx 30rpx;
        box-sizing: border-box;
        background-color: white;

        .item {
            width: 100%;
            padding: 30rpx 0;
            overflow: hidden;

            .title {
                color: $title-color;
            }
        }
    }
}

.wrap-footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 128rpx;
    z-index: 10;
    background-color: white;

    .item {
        width: 330rpx;
        height: 94rpx;
        line-height: 94rpx;
        text-align: center;
        border-radius: 50rpx;
        overflow: hidden;
    }

    .cancel {
        margin-left: 20rpx;
        border: 2rpx solid $theme-color;
        color: $theme-color;
    }

    .logout {
        margin: 0 20rpx;
        background: $grad-theme-color;
        color: $bg-text-color;
        flex: 1;
    }
}
</style>
